package mas.agents;

import test.ProgramSimulator;
import jade.core.Agent;
import jade.core.behaviours.OneShotBehaviour;
import jade.lang.acl.ACLMessage;

/**
 * Agent responsible for performing scenario simulation.
 * It acts withing the Blackboard specifications.
 *
 */
public class SimulationAgent extends Agent {
	private static final long serialVersionUID = -713850001421068878L;
	
	@Override
	protected void setup() {
		System.out.println("Simulation Agent online.");
		addBehaviour(new OneShotBehaviour() {
			@Override
			public void action() {
				ACLMessage msg = myAgent.blockingReceive();				
				if (msg.getContent().equals(Ontology.DB_READY_MSG)) {
					System.out.println(myAgent.getLocalName() + " recieved DB_READY. Starting simulation...");
					ProgramSimulator.startSimulation();
				}
			}
		});
	}
	
	@Override
	protected void takeDown() {
		System.out.println("Simulation Agent OFFLINE.");
	}

}
